package com.zyy.ui.utils;

import java.math.BigDecimal;

/**
 * @ClassName: DoubleUtil
 * @Description: Double类型公共处理类
 * @Author: zyy
 * @Date: 2020/04/25 18:36
 * @Version: 1.0
 */
public class DoubleUtil {
    public static double add(double v1, double v2) {
        BigDecimal b1 = BigDecimal.valueOf(v1);
        BigDecimal b2 = BigDecimal.valueOf(v2);
        return b1.add(b2).doubleValue();
    }

    public static double subtract(double v1, double v2) {
        BigDecimal b1 = BigDecimal.valueOf(v1);
        BigDecimal b2 = BigDecimal.valueOf(v2);
        return b1.subtract(b2).doubleValue();
    }

    public static void main(String[] args) {
        System.out.println(subtract(1.2, 1.02));
    }


}
